package com.itheima.mapper;

import com.itheima.common.entity.QueryPageBean;
import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckItemDao {
    void add(CheckItem checkItem);

    @Delete("delete from chuanzhi.t_checkitem where id=#{id}")
    void delete(Integer id);

    @Select("select * from chuanzhi.t_checkitem where id=#{id}")
    CheckItem selectBYID(Integer id );


    @Select("select * from chuanzhi.t_checkitem where name=#{name}")
    CheckItem selectBYName(String  name);

    @Select("select chuanzhi.t_checkitem.id from chuanzhi.t_checkitem  join chuanzhi.t_checkgroup_checkitem tcc " +
            "on chuanzhi.t_checkitem.id = tcc.checkitem_id    where tcc.checkgroup_id=#{id}")
    List<Integer>findCheckItemIdsByCheckGroupId(Integer id);

    void edit(CheckItem checkItem);

    @Select("select * from chuanzhi.t_checkitem")
    List<CheckItem>findPage(QueryPageBean page);

    @Select("select * from chuanzhi.t_checkitem")
    List<CheckItem>findAll();

    @Select("select * from chuanzhi.t_checkitem where id=#{id}")
    CheckItem findById(Integer id);
}
